package implementation.data.records;

import java.util.ArrayList;

import java.util.Collections;
import java.util.List;


import implementation.server.IReadOnlyUser;


public class CUserRecord implements IReadOnlyUser {
	
	
	private int _userId;
	private String _userName;
	private String _password;

	private List<Integer> _friendsList;

	public CUserRecord(){
		this._friendsList= Collections.synchronizedList(new ArrayList<Integer>());
	}
	
	public CUserRecord(int userId, String userName, String password){
		this._userId= userId;
		this._userName= userName;
		this._password= password;
		this._friendsList= Collections.synchronizedList(new ArrayList<Integer>());
	}
	
	public String get_userName(){
		return this._userName;
	}
	
	public int get_userId(){
		return this._userId;
	}
	
	public String get_password(){
		return this._password;
	}
	
	
	public void set_userId(int _userId) {
		this._userId = _userId;
	}


	public void set_userName(String _userName) {
		this._userName = _userName;
	}



	public void set_password(String _password) {
		this._password = _password;
	}

	public void set_friendsList(List<Integer> _friendsList) {
		this._friendsList = _friendsList;
	}
	
	
	public ArrayList<Integer> getFollowees(){
		
		ArrayList<Integer> tAnswer= new ArrayList<Integer>();
		
		synchronized(this){
			int tTo = this._friendsList.size();
			for(int index=0; index < tTo; index++)
				tAnswer.add(this._friendsList.get(index));
		}

		return tAnswer;	
	}
		
	public boolean addFriend(int friendId){
		return this._friendsList.add(friendId);
	}
	
	public boolean removeFriend(int friendId){
		return this._friendsList.remove((Object)friendId);
	}
	
	
	public CUserRecord clone(){
		
		CUserRecord tCUserRecord = new CUserRecord(this._userId, this._userName, this._password);
		
		synchronized(this){
			int tTo = this._friendsList.size();
			for(int index=0; index < tTo; index++)
				tCUserRecord.addFriend(this._friendsList.get(index));
		}
		
		
		return tCUserRecord;
	}

	@Override
	public ArrayList<Integer> getFollowers() {
		// TODO Auto-generated method stub
		return null;
	}

}
